using System;
using System.Collections.Generic;
using System.Data;
using System.Text;

namespace Kenly.DBFramework.Gateway
{
    /// <summary>
    /// Represents a database transaction.
    /// </summary>
    public class Transaction
    {
        ITableCommandExecutor _commandExecutor;

        /// <summary>
        /// 
        /// </summary>
        /// <param name="commandExecutor"></param>
        public Transaction(ITableCommandExecutor commandExecutor)
        {
            _commandExecutor = commandExecutor;
        }

       
         /// <summary>
        /// Commits a transaction.
        /// </summary>
        /// <returns></returns>
        public bool Commit()
        {
            if (_commandExecutor == null)
            {
                return false;
            }

            return _commandExecutor.Commit();
        }

         /// <summary>
        /// Rollbacks a transaction.
        /// </summary>
        /// <returns></returns>
        public bool Rollback()
        {
            if (_commandExecutor == null)
            {
                return false;
            }

            return _commandExecutor.Rollback();
        }
    }
}
